import Vue from 'vue'
import Vuex from 'vuex'
import router from '../router'; 
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 模拟的导航数据
    navData: [
      {
        id: 1,
        type: 'coach',
        name: '教练1',
        avatar: 'url_to_avatar1'
      },
      {
        id: 2,
        type: 'coach',
        name: '教练2',
        avatar: 'url_to_avatar2'
      },
      {
        id: 3,
        type: 'manager',
        name: '球队经理1',
        avatar: 'url_to_avatar3'
      }
    ]
  },
  getters: {
    navData: state => state.navData
  },
  mutations: {
    ADD_ITEM(state, item) {
      state.navData.push(item);
    },
    DELETE_ITEM(state,data) {
      state.navData = state.navData.filter(item =>item!=data );
    }
  },
  actions: {
    addItem({ commit }, item) {
      commit('ADD_ITEM', item);
    },
    deleteItem({ commit }, id) {
      commit('DELETE_ITEM', id);
    }
  },
  modules: {
  }
})
